<?php

namespace App\Providers;

use App\Models\Setting;
use Carbon\Carbon;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * 注册服务提供者
     *
     * @return void
     */
    public function register()
    {
        app('Dingo\Api\Transformer\Factory')->setAdapter(function ($app) {
            $fractal = new \League\Fractal\Manager;
            // 自定义的和fractal提供的
//            $serializer = new \League\Fractal\Serializer\DataArraySerializer();
//            $serializer = new \League\Fractal\Serializer\ArraySerializer();
//            $serializer = new \League\Fractal\Serializer\JsonApiSerializer();
            // 使用自定义转换层
            $serializer = new \App\Services\MySerializers();

            $fractal->setSerializer($serializer);
            return new \Dingo\Api\Transformer\Adapter\Fractal($fractal);
        });
    }

    /**
     * 引导应用程序服务
     *
     * @return void
     */
    public function boot()
    {
        Carbon::setLocale('zh');
    }
}
